﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Fonlow.CommandLineGui.Gui;

namespace Fonlow.CommandLineGui
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            string assemblyName = Properties.Settings.Default.AssemblyNameOfCommand;
            if (String.IsNullOrEmpty(assemblyName))
                assemblyName = "RobocopyParameters";

            CommandBase command = TypeLoader.LoadAssemblyWithCommand(assemblyName);
            if (command != null)
            {
                using (MainForm form = new MainForm(command))
                {
                    form.Text = "GUI for " + command.CommandName;
                    form.Left = 0;
                    form.Top = 0;
                    form.Height = Screen.PrimaryScreen.WorkingArea.Height;

                    Application.Run(form);
                }
            }
            else
            {
                System.Diagnostics.Trace.TraceWarning("fail");
                MessageBox.Show(String.Format("Can not load {0} to initialize.", assemblyName));
            }
        }
    }
}
